package com.example.yjhindex.service.serciceImpl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.example.yjhindex.entity.Article;
import com.example.yjhindex.mapper.ArticleMapper;
import com.example.yjhindex.service.ArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    public List<Article> queryAllArticle(int page,int size) {
        IPage<Article> p = new Page<>(page,size);
        final IPage<Article> iPage = articleMapper.selectPage(p, null);
        System.out.println("iPage.getRecords() = " + iPage.getRecords());
        return iPage.getRecords();
    }

    @Override
    public Article getArticleById(String id) {
        return articleMapper.selectById(id);
    }
}
